﻿using System.Collections.Generic;
using BUS;
using System.Web;

namespace App_Code
{
    public class Account
    {
        public static KhachHangBUS KhachHang { get; private set; }
        public static bool CheckLogin(string user, string pass)
        {
            var kh = new KhachHangBUS { TenDangNhap = user, MatKhau = pass.EncryptMD5() };
            if (kh.CheckLogin())
            {
                HttpContext.Current.Session["user"] = kh.TenDangNhap;
                HttpContext.Current.Session["hoten"] = kh.HoTen;
                return true;
            }
            return false;
        }
        public static void Register(KhachHangBUS kh)
        {
            kh.Add();
        }

        public static bool GetNameByUserName(string UserName)
        {
            var kh = new KhachHangBUS { TenDangNhap = UserName };
            if (kh.GetbyUserName())
            {
                KhachHang = kh;
                return true;
            }
            return false;
        }

        public static void ChangePassWord(string newPass)
        {
            KhachHang.MatKhau = newPass.EncryptMD5();
            KhachHang.ChangePass();
        }
     
    }


}